package api_day13;

public class Producer extends Thread{
    public Product product;

    public Producer(Product product) {
        this.product = product;
    }

    @Override
    public void run() {
        while (true){
            product.lock.lock();
            while (product.flag){
                try {
                    product.pro.await();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            while (product.product < 10){
                product.product += 5;
                System.out.println("生产了五个");
                product.flag = true;
                product.con.signal();
            }
            product.lock.unlock();
        }
    }
}